package com.tanhua.manage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.manage.domain.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface LogMapper extends BaseMapper<Log> {

    //新注册、登陆用户数
    @Select("SELECT COUNT(user_Id) FROM tb_log WHERE log_time = #{now} AND type = #{type}")
    Long queryNewUserToday(@Param("now") String now, @Param("type") String type);

    //活跃用户数
    @Select("SELECT COUNT(DISTINCT user_Id) FROM tb_log WHERE log_time = #{now} AND type = '0101'")
    Long queryActiveUser(String now);

    //次日留存用户数
    @Select("SELECT COUNT(DISTINCT user_Id) FROM tb_log WHERE log_time = #{now} AND user_Id IN (SELECT COUNT(user_Id) FROM tb_log WHERE log_time = #{yes} AND type = '0102') ")
    Long queryRetention1d(@Param("now") String now, @Param("yes") String yes);
}
